Skip to content

feat: WatsonXChatGenerator - support Tools and use the StreamingChunk fields#2902

Merged
anakin87 merged 10 commits intodeepset-ai:mainfrom
maxdswain:watsonxchatgenerator-streamingchunk
Mar 12, 2026
Merged

feat: WatsonXChatGenerator - support Tools and use the StreamingChunk fields#2902
anakin87 merged 10 commits intodeepset-ai:mainfrom
maxdswain:watsonxchatgenerator-streamingchunk

Conversation

@maxdswain
Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

feat: Update WatsonXChatGenerator to use the StreamingChunk index and finish_reason fields.

How did you test it?

Updated existing tests.

Notes for the reviewer

Checklist

@maxdswain maxdswain requested a review from a team as a code owner March 1, 2026 18:17
@maxdswain maxdswain requested review from anakin87 and removed request for a team March 1, 2026 18:17
@github-actions github-actions Bot added integration:watsonx type:documentation Improvements or additions to documentation labels Mar 1, 2026
Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

I think that a little more adaptation work will be needed, especially in handling tool calls.

I suggest taking inspiration from #2078 and #2108 (but keeping in mind that each provider has its own particularities and code can be very different).

Also, I'd like to see a test with real chunks coming from WatsonX (similar test for Google GenAI).

@maxdswain
Copy link
Copy Markdown
Contributor Author

Thanks for the contribution!

I think that a little more adaptation work will be needed, especially in handling tool calls.

I suggest taking inspiration from #2078 and #2108 (but keeping in mind that each provider has its own particularities and code can be very different).

Also, I'd like to see a test with real chunks coming from WatsonX (similar test for Google GenAI).

Okay, I'll convert it to a draft for now and work on it a bit more to add support for tool calls as well as more tests. I'll let you know when it's ready.

@maxdswain maxdswain marked this pull request as draft March 5, 2026 20:38
@maxdswain maxdswain marked this pull request as ready for review March 11, 2026 18:32
@maxdswain
Copy link
Copy Markdown
Contributor Author

Hi @anakin87, this PR should now be ready to be reviewed. I have added a bunch of tests for tool calling (mirroring the Google Gen AI integration) as well as a test that converts real chunks I got from making requests to Watsonx.ai.

Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Left two initial comments

Comment thread integrations/watsonx/pyproject.toml
Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are not running on PRs from forks but when I run hatch run test:integration locally, I get 4 tests failing:

FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_toolset - assert '{\n  "city": "Paris"\n}' == {'city': 'Paris'}
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_tools_streaming - assert '{\n  "city": "Paris"\n}' == {'city': 'Paris'}
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_mixed_tools - AssertionError: Expected 2 tool calls, got 1
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_async_with_tools - assert '{\n  "city": "Paris"\n}' == {'city': 'Paris'}

Could you please investigate?

@maxdswain
Copy link
Copy Markdown
Contributor Author

Tests are not running on PRs from forks but when I run hatch run test:integration locally, I get 4 tests failing:

FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_toolset - assert '{\n  "city": "Paris"\n}' == {'city': 'Paris'}
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_tools_streaming - assert '{\n  "city": "Paris"\n}' == {'city': 'Paris'}
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_with_mixed_tools - AssertionError: Expected 2 tool calls, got 1
FAILED tests/test_chat_generator.py::TestWatsonxChatGeneratorIntegration::test_live_run_async_with_tools - assert '{\n  "city": "Paris"\n}' == {'city': 'Paris'}

Could you please investigate?

Thanks for spotting this, I was running my local tests using an IBM EU cloud account so had changed the endpoint as well as the model as less models are supported on the EU cloud when running the tests. I have now updated the tool call parsing to better handle output from the default model.

@anakin87 anakin87 changed the title feat: Update WatsonXChatGenerator to use the StreamingChunk fields feat: WatsonXChatGenerator - support Tools and use the StreamingChunk fields Mar 12, 2026
Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@anakin87 anakin87 merged commit 9e5e5d3 into deepset-ai:main Mar 12, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:watsonx type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Update WatsonXChatGenerator to use the StreamingChunk fields

2 participants